package org.example.observer;

import java.util.HashMap;

public class Count implements Observer{

    int wordCount;
    StringBuilder sb = new StringBuilder();

    @Override
    public void response(String word) {
        wordCount++;
        sb.append(word);
    }

    @Override
    public void show() {
        System.out.println("单词总数："+wordCount);
        // 包括空格换行
        System.out.println("字符总数量："+(sb.toString().length()+wordCount));
    }
}
